package com.leyou.user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.leyou.common.constants.RegexPatterns;
import com.leyou.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author BaiZY on 2020/9/12.
 * @version 1.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_address")
public class Address{
    @TableId(type = IdType.AUTO)
    private Long id;

    private Long userId;

    @NotNull(message = "收件人不能为空")
    @Length(min = 2, max = 30, message = "用户名的长度在4-30之间")
    private String addressee;

    @NotNull(message = "省不能为空")
    private String province;

    @NotNull(message = "市不能为空")
    private String city;

    @NotNull(message = "县区不能为空")
    private String district;

    @NotNull(message = "详细地址不能为空")
    private String street;

    @NotNull(message = "手机号码不为空")
    @Pattern(regexp = RegexPatterns.PHONE_REGEX, message = "手机号码格式不匹配")
    private String phone;

    private String postcode;

    @NotNull(message = "默认地址不为空")
    private boolean isDefault;

    private String alias;
}
